package codingforgreat.lchot150;

public class Lc050 {
    public double myPow(double x, int n) {
        if(n == 0){
            return 1L;
        }
        int k = n == Integer.MIN_VALUE ? Math.abs( n + 1 ) : Math.abs(n);
        double temp = x;
        double res = 1L;
        while(k != 0){
            if((k & 1) != 0){
                res *= temp;
            }
            k >>= 1;
            temp *= temp;
        }
        if(n == Integer.MIN_VALUE){
            res *= x;
        }
        return n < 0 ? (1D / res) : res;
    }
}
